import Vue from 'vue'
import VueRouter from 'vue-router'
// 引入首页
import Login from '../views/Login.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login,
    meta: {
      title: "福玻斯--登陆"
        }
  },
 
  // 注册页面配置
{
  path: '/reg',
  name: 'Reg',
  meta:{
    title:'福玻斯--注册'
     },
  component: () => import('../views/register.vue'),
},

  // 页面配置
{
  path: '/Index',
  name: 'index',
  meta:{
    title:'福玻斯--选型'
     },
  component: () => import('../views/Index.vue'),
},
     // 404页面配置
{
  // 所有没有配置的路径
  path: '*',
  name: 'NotFount',
  meta: {
    title: "404页面"
     },
  component: () => import('../views/NotFount.vue'),
},
{
  path: '/system',
  name: 'system',
  component: () => import('../views/Index.vue'),
},

]


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// 路由守卫必须在router赋值后书写
// 路由前置守卫，在路由跳转前触发
router.beforeEach((to,from,next)=>{
  // from从哪来，to到哪去
  // 用Dom修改标题
  document.title=to.meta.title
  // 放行，允许路由继续运行
  next()
})


export default router
